import { getCurrentPosition, getPoint } from "../../utils/bdMapHelper";
// 异步获取当前城市信息
export const getLocalCityAction = () => {
  return async (dispatch) => {
    const res = await getCurrentPosition();
    dispatch({
      type: "initCity",
      value: res
    })
  }
}

// 改变当前城市
export const changeCityAction = (cityName) => {
  return async (dispatch) => {
    // res={ name , point}
    const point = await getPoint({ city: cityName });
    const res = {
      name: cityName,
      point
    }
    dispatch({
      type: "initCity",
      value: res
    })
  }
}

// 清空当前城市
export const clearCityAction = () => {
  return {
    type: "clearCity"
  }
}